
***Log file
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Replication\Log files\Main Figures"
clear all
log using Figs1-2.log, replace

***Figure 1 -Panel A
clear
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Data"
use LPSU_MainSample_Sep2024, replace

keep id ipo countryname

duplicates drop
bysort countryname ipo: egen count_obs=count(id)
keep countryname ipo count_obs
duplicates drop

reshape wide count_obs, i(countryname) j(ipo)

label var count_obs0 "# withdrawn IPOs"
label var count_obs1 "# completed IPOs"
label var countryname "Country"
gen total=count_obs0+count_obs1
gen withdrawn=count_obs0/total
label var withdrawn "% Withdrawn"
label var total "Total filings"
encode countryname, gen(country)

twoway (connected withdrawn country, lpattern(dash) lcolor(green) msymbol(T) mcolor(red) ylab(0(0.1)0.3) yscale(range(0 0.3))) (bar  total country,  fcolor(none) lcolor(blue) yaxis(2) ), title(IPO filings per country) ///
xlabel(1 "Austria" 2 "Belgium" 3 "Denmark" 4 "Finland" 5 "France" 6 "Germany" 7 "Greece" 8 "Ireland" 9  "Italy" 10  "Netherlands" 11  "Norway" 12  "Portugal" 13  "Spain" 14 "Sweden" 15  "Switzerland" 16  "United Kingdom", angle(45))

graph export "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Figures\1A.tif", as(tif) replace

graph export Fig1a.pdf, replace 

***Figure 1b
clear
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Data"
use LPSU_MainSample_Sep2024, replace
***
keep id ipo filing_yr
duplicates drop
bysort filing_y ipo: egen count_obs=count(id)
keep fil ipo count_obs
duplicates drop

reshape wide count_obs, i(filing_yr) j(ipo)

label var count_obs0 "# withdrawn IPOs"
label var count_obs1 "# completed IPOs"
label var filing_yr "Filing year"
gen total=count_obs0+count_obs1
gen withdrawn=count_obs0/total
label var total "Total filings"
label var withdrawn "% withdrawn"


twoway (connected withdrawn filing_yr, lpattern(dash) lcolor(red) mcolor(blue) ylab(0(0.1)0.7) yscale(range(0 0.7))) (bar  total filing_yr,  fcolor(none) lcolor(black) yaxis(2)) , xscale(range(1997 2017)) xlab(1997(1)2017) xlabel(, angle(45)) title(IPO filings per year)
graph export "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Figures\1B.tif", as(tif) replace

graph export Fig1b.pdf, replace 

***Figure 2
clear
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Data"
use LPSU_MainSample_Sep2024, replace

keep id ipo year_ar
duplicates drop
bysort year_ar ipo: egen count_obs=count(id)
keep year_ar ipo count_obs
duplicates drop

reshape wide count_obs, i(year_ar) j(ipo)

label var count_obs0 "# withdrawn IPOs"
label var count_obs1 "# completed IPOs"
label var year_ar "Event year"

**Changing x-axis position to avoid overlap in the figure
gen year_ar1= year_around_ipo -0.11
gen year_ar2= year_around_ipo +0.11

twoway (bar count_obs0 year_ar1, lcolor(red) mcolor(blue) fintensity(10) bcolor(red) barwidth(0.2)) || ///
(bar count_obs1 year_ar2,  fcolor(none) lcolor(black)  fcolor(none) lcolor(black) msize(large) fintensity(20)  barwidth(0.2) yaxis(2) ) ///
, xscale(range(-2 2)) xlab(-2(1)2) xlabel(, angle(45)) xline(-.5, lpattern(dash)) xtitle("Event year")  title(Observations by event year) ///
ysca(axis(1) range(0 400)) ylab(0(100)400, axis(1)) ysca(axis(2) r(0 2688)) ylab(0 (700) 2688, axis(2)) 
graph export "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Figures\2.tif", as(tif) replace

graph export Fig2.pdf, replace 


***Log file
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Replication\Log files\Main Figures"
log close
graphlog using Figs1-2.log, lspacing(1) replace

